home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Sessions / Completions / Completions Source / Pipes / PipeInput.h < prev    next >
Encoding:
Text File  |  1998-06-19  |  1.7 KB  |  89 lines  |  [TEXT/CWIE]

  1. // PipeInput.h
  2.  
  3. #ifndef PipeInput_h
  4. #define PipeInput_h
  5.  
  6. #ifndef BufferMaster_h
  7. #include "BufferMaster.h"
  8. #endif
  9. #ifndef Sleeper_h
  10. #include "Sleeper.h"
  11. #endif
  12. #ifndef PipePacket_h
  13. #include "PipePacket.h"
  14. #endif
  15. #ifndef TaskSequencer_h
  16. #include "TaskSequencer.h"
  17. #endif
  18.  
  19. class TeeBase;
  20.  
  21. class PipeInput
  22.   {
  23.     friend class PipeInputMaster;
  24.     
  25.     private:
  26.         BufferMaster buffer;
  27.         const Data ring;
  28.         TeeBase& pipe;
  29.         
  30.         PipePacket entering;
  31.         PipePacket exiting;
  32.         
  33.         Sleeper sleep;
  34.         uint32 acceptLength;
  35.         
  36.         TaskSequencer<PipeInput> sequence;
  37.         typedef TaskStep<PipeInput> Step;
  38.         
  39.         PipeInput( Data theRing, TeeBase& thePipe );
  40.         void Reset();
  41.         void PushIn( PipePacket );
  42.         void PushOut();
  43.         uint32 Audit() const;
  44.         const uint8 *ExitingStart() const;
  45.         const uint8 *EnteringEnd() const;
  46.         
  47.         void MoveBuffer();
  48.         
  49.         Step DoPass( bool dying, DeferredTaskTime );
  50.         
  51.         Step TryAccept( bool dying, DeferredTaskTime );
  52.         
  53.         Step StartFlush( bool dying, DeferredTaskTime );
  54.         Step FinishFlush( bool dying, DeferredTaskTime );
  55.         
  56.     public:
  57.         ::Buffer& Buffer()                            { return buffer; }
  58.         const ::Buffer& Buffer() const            { return buffer; }
  59.         
  60.         uint32 PotentialLength() const;
  61.         uint32 RingLength() const                    { return ring.Length(); }
  62.  
  63.         uint32 LargestAcceptSize() const;
  64.         uint32 ReasonableAcceptSize() const;
  65.         uint32 ReasonablePassSize() const;
  66.  
  67.         Task *Pass();
  68.         Task *Accept( uint32 requiredSize );
  69.         Task *Flush();
  70.   };
  71.  
  72. class PipeInputMaster: public PipeInput
  73.   {
  74.     public:
  75.         PipeInputMaster( Data theRing, TeeBase& thePipe )
  76.           : PipeInput( theRing, thePipe )
  77.           {}
  78.         
  79.         ~PipeInputMaster()        {}
  80.         
  81.         PipeInput::Reset;
  82.         PipeInput::PushIn;
  83.         PipeInput::Audit;
  84.         PipeInput::ExitingStart;
  85.         PipeInput::EnteringEnd;
  86.   };
  87.  
  88. #endif
  89.